package com.baselib.libnetwork.net.callback;

import com.baselib.libnetwork.net.base.Callback;
import com.baselib.libnetwork.net.model.ResultResponse;

import java.io.File;

import okhttp3.Response;

/**
 * @author lixuce
 * @version v1.0
 * @description 文件的回调下载进度监听
 * @since 2017/12/4
 */

public abstract class FileCallback<T> implements Callback<File> {

    private FileConvert convert;    //文件转换类

//    public FileCallback() {
//        this(null);
//    }

//    public FileCallback(String destFileName) {
//        this(null, destFileName);
//    }

    public FileCallback(String destFileDir, String destFileName) {
        convert = new FileConvert(destFileDir, destFileName);
        convert.setCallback(this);
    }


    @Override
    public File convertResponse(Response response) throws Exception {
        File file = convert.convertResponse(response);
        response.close();
        return file;
    }

    @Override
    public void onDownloadSuccess(File file) {

    }

    @Override
    public void onSuccess(ResultResponse<File> response) {

    }


    @Override
    public void onProgress(float progress) {

    }
}
